package com.zhuang.designpattern.facade;

/**
 * description: Light
 * date: 2022/9/18 9:50
 * author: Zhuang
 * version: 1.0
 */
public class SmartAppliancesFacade {
    private final Light light;
    private final TV tv;
    private final AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }

    //私有打开方法 外界访问不了
    //一键打开
    private void on() {
        light.on();
        tv.on();
        airCondition.on();
    }

    //私有关闭方法 外界访问不了
    //一键关闭
    private void off() {
        light.off();
        tv.off();
        airCondition.off();
    }

    //判断方法
    public void say(String message) {
        if (message.contains("打开")) {
            on();
        } else if (message.contains("关闭")) {
            off();
        } else {
            System.out.println("你说的指令我听不懂！！！");
        }

    }
}
